home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / source / blt / stretch.asm < prev    next >
Encoding:
Assembly Source File  |  1993-09-21  |  42.2 KB  |  1,472 lines

  1. page    ,132
  2. ;----------------------------Module-Header------------------------------;
  3. ; Module Name: STRETCH32.ASM
  4. ;
  5. ; StretchBLT for DIBs
  6. ;
  7. ; NOTES:
  8. ;       - Does not handle mirroring in x or y.
  9. ;       - Does not handle pixel translation
  10. ;       - will not work "in place"
  11. ;
  12. ;       - This is the 32 bit version (32 bit code seg that is...)
  13. ;
  14. ;  AUTHOR: ToddLa (Todd Laney) Microsoft
  15. ;
  16. ;-----------------------------------------------------------------------;
  17. ?PLM=1
  18. ?WIN=0
  19.     .xlist
  20.         include cmacro32.inc
  21. ;       include cmacros.inc
  22.         include windows.inc
  23.     .list
  24.  
  25. sBegin  Data
  26. sEnd    Data
  27.  
  28. ifndef SEGNAME
  29.     SEGNAME equ <_TEXT32>
  30. endif
  31.  
  32. createSeg %SEGNAME, CodeSeg, word, public, CODE
  33.  
  34. sBegin  CodeSeg
  35.         .386
  36.         assumes cs,CodeSeg
  37.         assumes ds,nothing
  38.         assumes es,nothing
  39.  
  40. ;--------------------------------------------------------------------------;
  41. ;
  42. ;   DDA type constants returned from stretch_init_dda
  43. ;
  44. ;--------------------------------------------------------------------------;
  45.  
  46. STRETCH_1to1    equ     (0*4)       ;   dst = src
  47. STRETCH_1to2    equ     (1*4)       ;   dst = src * 2
  48. STRETCH_1to4    equ     (2*4)       ;   dst = src * 4
  49. STRETCH_1toN    equ     (3*4)       ;   dst > src
  50. STRETCH_2to1    equ     (4*4)       ;   dst = src / 2
  51. STRETCH_4to1    equ     (5*4)       ;   dst = src / 4
  52. STRETCH_Nto1    equ     (6*4)       ;   dst < src
  53. STRETCH_VOID    equ     (7*4)       ;   not used.
  54.  
  55. ;--------------------------------------------------------------------------;
  56. ;
  57. ; x_stretch_functions
  58. ;
  59. ;     functions for stretching a single scanline, this table is indexed
  60. ;     by the x dda type (see above) and the bit depth
  61. ;
  62. ;--------------------------------------------------------------------------;
  63.  
  64. x_stretch_functions label dword             ;function table for x_stretch
  65.  
  66. x_stretch_8_functions label dword           ;function table for x_stretch
  67.         dd      x_stretch_1to1              ; STRETCH_1to1
  68.         dd      x_stretch_8_1to2            ; STRETCH_1to2
  69.         dd      x_stretch_8_1to4            ; STRETCH_1to4
  70.         dd      x_stretch_8_1toN            ; STRETCH_1toN
  71.         dd      x_stretch_8_Nto1            ; STRETCH_2to1
  72.         dd      x_stretch_8_Nto1            ; STRETCH_4to1
  73.         dd      x_stretch_8_Nto1            ; STRETCH_Nto1
  74.         dd      0
  75.  
  76. x_stretch_16_functions label dword          ;function table for x_stretch
  77.         dd      x_stretch_1to1              ; STRETCH_1to1
  78.         dd      x_stretch_16_1to2           ; STRETCH_1to2
  79.         dd      x_stretch_16_1toN           ; STRETCH_1to4
  80.         dd      x_stretch_16_1toN           ; STRETCH_1toN
  81.         dd      x_stretch_16_Nto1           ; STRETCH_2to1
  82.         dd      x_stretch_16_Nto1           ; STRETCH_4to1
  83.         dd      x_stretch_16_Nto1           ; STRETCH_Nto1
  84.         dd      0
  85.  
  86. x_stretch_24_functions label dword          ;function table for x_stretch
  87.         dd      x_stretch_1to1              ; STRETCH_1to1
  88.         dd      x_stretch_24_1toN           ; STRETCH_1to2
  89.         dd      x_stretch_24_1toN           ; STRETCH_1to4
  90.         dd      x_stretch_24_1toN           ; STRETCH_1toN
  91.         dd      x_stretch_24_Nto1           ; STRETCH_2to1
  92.         dd      x_stretch_24_Nto1           ; STRETCH_4to1
  93.         dd      x_stretch_24_Nto1           ; STRETCH_Nto1
  94.         dd      0
  95.  
  96. x_stretch_32_functions label dword          ;function table for x_stretch
  97.         dd      x_stretch_1to1              ; STRETCH_1to1
  98.         dd      x_stretch_32_1to2           ; STRETCH_1to2
  99.         dd      x_stretch_32_1toN           ; STRETCH_1to4
  100.         dd      x_stretch_32_1toN           ; STRETCH_1toN
  101.         dd      x_stretch_32_Nto1           ; STRETCH_2to1
  102.         dd      x_stretch_32_Nto1           ; STRETCH_4to1
  103.         dd      x_stretch_32_Nto1           ; STRETCH_Nto1
  104.         dd      0
  105.  
  106. ;--------------------------------------------------------------------------;
  107. ;
  108. ; y_stretch_functions
  109. ;
  110. ;     functions for stretching in the y direction, indexed by the y dda type
  111. ;
  112. ;--------------------------------------------------------------------------;
  113.  
  114. y_stretch_functions label dword             ;function table for y_stretch
  115.         dd      y_stretch_1toN              ; STRETCH_1to1
  116.         dd      y_stretch_1toN              ; STRETCH_1to2
  117.         dd      y_stretch_1toN              ; STRETCH_1to4
  118.         dd      y_stretch_1toN              ; STRETCH_1toN
  119.         dd      y_stretch_Nto1              ; STRETCH_2to1
  120.         dd      y_stretch_Nto1              ; STRETCH_4to1
  121.         dd      y_stretch_Nto1              ; STRETCH_Nto1
  122.  
  123. ;--------------------------------------------------------------------------;
  124. ;
  125. ; stretch_functions
  126. ;
  127. ;   special case stretching routines, used if (y dda type) = (x dda type)
  128. ;   (and entry exists in this table)
  129. ;
  130. ;   these functions stretch the entire image.
  131. ;
  132. ;--------------------------------------------------------------------------;
  133.  
  134. stretch_functions label dword
  135.  
  136. stretch_8_functions label dword
  137.         dd      0                           ; STRETCH_1to1
  138.         dd      stretch_8_1to2              ; STRETCH_1to2
  139.         dd      0                           ; STRETCH_1to4
  140.         dd      0                           ; STRETCH_1toN
  141.         dd      0                           ; STRETCH_2to1
  142.         dd      0                           ; STRETCH_4to1
  143.         dd      0                           ; STRETCH_Nto1
  144.         dd      0
  145.  
  146. stretch_16_functions label dword
  147.         dd      0                           ; STRETCH_1to1
  148.         dd      stretch_16_1to2             ; STRETCH_1to2
  149.         dd      0                           ; STRETCH_1to4
  150.         dd      0                           ; STRETCH_1toN
  151.         dd      0                           ; STRETCH_2to1
  152.         dd      0                           ; STRETCH_4to1
  153.         dd      0                           ; STRETCH_Nto1
  154.         dd      0
  155.  
  156. stretch_24_functions label dword
  157.         dd      0                           ; STRETCH_1to1
  158.         dd      0                           ; STRETCH_1to2
  159.         dd      0                           ; STRETCH_1to4
  160.         dd      0                           ; STRETCH_1toN
  161.         dd      0                           ; STRETCH_2to1
  162.         dd      0                           ; STRETCH_4to1
  163.         dd      0                           ; STRETCH_Nto1
  164.         dd      0
  165.  
  166. stretch_32_functions label dword
  167.         dd      0                           ; STRETCH_1to1
  168.         dd      0                           ; STRETCH_1to2
  169.         dd      0                           ; STRETCH_1to4
  170.         dd      0                           ; STRETCH_1toN
  171.         dd      0                           ; STRETCH_2to1
  172.         dd      0                           ; STRETCH_4to1
  173.         dd      0                           ; STRETCH_Nto1
  174.         dd      0
  175.  
  176. ;--------------------------------------------------------------------------;
  177. ;
  178. ;   StretchDIB()
  179. ;
  180. ;   Entry:
  181. ;       Stack based parameters as described below.
  182. ;
  183. ;   Returns:
  184. ;       none
  185. ;
  186. ;   Registers Preserved:
  187. ;       DS,ES,ESI,EDI,EBP
  188. ;
  189. ;--------------------------------------------------------------------------;
  190.         assumes ds,nothing
  191.         assumes es,nothing        
  192.  
  193. cProc   StretchDIB,<FAR,PUBLIC,PASCAL>,<>
  194.         parmD   biDst                   ;--> BITMAPINFO of dest
  195.         parmD   lpDst                   ;--> to destination bits
  196.         parmW   DstX                    ;Destination origin - x coordinate
  197.         parmW   DstY                    ;Destination origin - y coordinate
  198.         parmW   DstXE                   ;x extent of the BLT
  199.         parmW   DstYE                   ;y extent of the BLT
  200.         parmD   biSrc                   ;--> BITMAPINFO of source
  201.         parmD   lpSrc                   ;--> to source bits
  202.         parmW   SrcX                    ;Source origin - x coordinate
  203.         parmW   SrcY                    ;Source origin - y coordinate
  204.         parmW   SrcXE                   ;x extent of the BLT
  205.         parmW   SrcYE                   ;y extent of the BLT
  206.  
  207.         localD  x_stretch               ;X stretch function
  208.         localD  y_stretch               ;Y stretch function
  209.  
  210.         localD  x_stretch_dda           ;X stretch DDA
  211.         localD  x_stretch_dda_fract     ;X stretch DDA fract
  212.  
  213.         localD  y_stretch_dda           ;Y stretch DDA
  214.         localD  y_stretch_dda_fract     ;Y stretch DDA fract
  215.  
  216.         localD  ScanCount               ;number of scans left to do
  217.         localD  Yerr                    ;Y dda error
  218.  
  219.         localD  SrcWidth                ;width of source dib in bytes
  220.         localD  DstWidth                ;width of dest in bytes
  221.  
  222.         localD  SrcBytes                ;width of source blt in bytes
  223.         localD  DstBytes                ;width of dest blt in bytes
  224.  
  225.         localD  SrcInc
  226.         localD  DstInc
  227.  
  228.         localD  lDstXE                  ;x extent of the BLT
  229.         localD  lDstYE                  ;y extent of the BLT
  230.         localD  lSrcXE                  ;x extent of the BLT
  231.         localD  lSrcYE                  ;y extent of the BLT
  232. cBegin
  233.         cld
  234.  
  235.         push    esi
  236.         push    edi
  237.         push    ds
  238.  
  239.     call    stretch_init    ; init all the frame variables
  240.         jc      short StretchDIBExit
  241.  
  242.         call    y_stretch       ; do it!
  243.  
  244. StretchDIBExit:
  245.         pop     ds
  246.         pop     edi
  247.         pop     esi
  248. cEnd
  249.  
  250. ;--------------------------------------------------------------------------;
  251. ;
  252. ;   stretch_init_dda
  253. ;
  254. ;       initialize the parameters of a DDA from ax to dx.
  255. ;
  256. ;   Entry:
  257. ;       eax         - source coord
  258. ;       edx         - dest coord
  259. ;   Returns:
  260. ;       eax         - STRETCH_1to1
  261. ;                     STRETCH_1to2
  262. ;                     STRETCH_1to4
  263. ;                     STRETCH_1toN
  264. ;                     STRETCH_2to1
  265. ;                     STRETCH_4to1
  266. ;                     STRETCH_Nto1
  267. ;
  268. ;       edx         - src / dst
  269. ;       ebx         - src / dst fraction
  270. ;
  271. ;--------------------------------------------------------------------------;
  272.  
  273. stretch_init_dda proc near
  274.  
  275.         cmp     eax,edx
  276.         je      short stretch_init_dda_1to1
  277.         ja      short stretch_init_dda_Nto1
  278.         errn$   stretch_init_dda_1toN
  279.  
  280. stretch_init_dda_1toN:
  281.         mov     ebx,eax
  282.         add     ebx,ebx
  283.         cmp     ebx,edx
  284.         je      short stretch_init_dda_1to2
  285.         add     ebx,ebx
  286.         cmp     ebx,edx
  287.         je      short stretch_init_dda_1to4
  288.  
  289.         mov     ebx,edx             ; ebx = dest
  290.         mov     edx,eax             ; edx = src
  291.         xor     eax,eax             ; edx:eax = src<<32
  292.         div     ebx                 ; eax = (src<<32)/dst
  293.  
  294.         mov     ebx,eax
  295.         xor     edx,edx
  296.         mov     eax,STRETCH_1toN
  297.         ret
  298.  
  299. stretch_init_dda_Nto1:
  300.         mov     ebx,edx
  301.         add     ebx,ebx
  302.         cmp     eax,ebx
  303.         je      short stretch_init_dda_2to1
  304.         add     ebx,ebx
  305.         cmp     eax,ebx
  306.         je      short stretch_init_dda_4to1
  307.  
  308.         mov     ebx,edx             ; ebx = dst
  309.         xor     edx,edx             ; edx:eax = src
  310.         mov     eax,eax
  311.         div     ebx                 ; eax = src/dst edx = rem
  312.         push    eax
  313.         xor     eax,eax             ; edx:eax = rem<<32
  314.         div     ebx                 ; eax = rem<<32/dst
  315.         mov     ebx,eax
  316.         pop     edx
  317.         mov     eax,STRETCH_Nto1
  318.         ret
  319.  
  320. stretch_init_dda_1to1:
  321.         mov     edx, 1
  322.         xor     ebx, ebx
  323.         mov     eax, STRETCH_1to1
  324.         ret
  325.  
  326. stretch_init_dda_1to2:
  327.         xor     edx, edx
  328.         mov     ebx, 80000000h
  329.         mov     eax, STRETCH_1to2
  330.         ret
  331.  
  332. stretch_init_dda_1to4:
  333.         xor     edx, edx
  334.         mov     ebx, 40000000h
  335.         mov     eax, STRETCH_1to4
  336.         ret
  337.  
  338. stretch_init_dda_2to1:
  339.         mov     edx, 2
  340.         xor     ebx, ebx
  341.         mov     eax, STRETCH_2to1
  342.         ret
  343.  
  344. stretch_init_dda_4to1:
  345.         mov     edx, 4
  346.         xor     ebx, ebx
  347.         mov     eax, STRETCH_4to1
  348.         ret
  349.  
  350. stretch_init_dda endp
  351.  
  352. ;--------------------------------------------------------------------------;
  353. ;
  354. ;   stretch_init
  355. ;
  356. ;   init local frame vars for StretchDIB
  357. ;
  358. ;   ENTRY:
  359. ;       ss:bp   --> stretchdib frame
  360. ;
  361. ;--------------------------------------------------------------------------;
  362.  
  363. stretch_init_error:
  364.         stc
  365.         ret
  366.  
  367. stretch_init proc near
  368.  
  369. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  370. ;   expand word params to dwords
  371. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  372.         movzx   eax,DstXE
  373.         movzx   ebx,DstYE
  374.         movzx   ecx,SrcXE
  375.         movzx   edx,SrcYE
  376.  
  377.         mov     lDstXE,eax
  378.         mov     lDstYE,ebx
  379.         mov     lSrcXE,ecx
  380.         mov     lSrcYE,edx
  381.  
  382. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  383. ; Make sure they didn't give us an extent of zero anywhere
  384. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  385.         or      eax,eax
  386.         jz      short stretch_init_error
  387.  
  388.         or      ebx,ebx
  389.         jz      short stretch_init_error
  390.  
  391.         or      ecx,ecx
  392.         jz      short stretch_init_error
  393.  
  394.         or      edx,edx
  395.         jz      short stretch_init_error
  396.  
  397. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  398. ;   make sure the bit depth of the source and dest match and are valid
  399. ;   we only handle 8,16,24 bit depths.
  400. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  401.         xor     edi,edi                     ; be sure the high words are clear.
  402.     xor    esi,esi
  403.         xor     ecx,ecx
  404.  
  405.         lds     si, biSrc
  406.         les     di, biDst
  407.  
  408.         mov     cx, [esi].biBitCount        ; get the bit depth
  409.         cmp     cx, es:[edi].biBitCount     ; make sure they are the same.
  410.         jne     short stretch_init_error
  411.  
  412.         cmp     ecx,8
  413.         je      short stretch_init_bit_depth_ok
  414.  
  415.         cmp     ecx,16
  416.         je      short stretch_init_bit_depth_ok
  417.  
  418.         cmp     ecx,24
  419.         je      short stretch_init_bit_depth_ok
  420.  
  421.         cmp     ecx,32
  422.         jne     short stretch_init_error
  423.         errn$   stretch_init_bit_depth_ok
  424.  
  425. stretch_init_bit_depth_ok:
  426.  
  427. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  428. ;
  429. ;  Set up the initial source pointer
  430. ;
  431. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  432.         mov     eax,[esi].biWidth
  433.         mul     ecx
  434.         add     eax,31
  435.         and     eax,not 31
  436.         shr     eax,3
  437.         mov     SrcWidth,eax
  438.         mov     SrcInc,eax
  439.  
  440.         lds     si,lpSrc
  441.  
  442.         movzx   edx,SrcY
  443.         mul     edx
  444.     add    esi,eax
  445.  
  446.         movzx   eax,SrcX
  447.         mul     ecx
  448.         shr     eax,3
  449.         add     esi,eax
  450.  
  451.         mov     eax,lSrcXE
  452.         mul     ecx
  453.         shr     eax,3
  454.         mov     SrcBytes,eax
  455.         sub     SrcInc,eax
  456.  
  457. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  458. ;
  459. ;  Set up the initial dest pointer
  460. ;
  461. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  462.         mov     eax,es:[edi].biWidth
  463.         mul     ecx
  464.         add     eax,31
  465.         and     eax,not 31
  466.         shr     eax,3
  467.         mov     DstWidth,eax
  468.         mov     DstInc,eax
  469.  
  470.         cmp     es:[edi].biHeight,0            ; init a upside down DIB
  471.         jge     short @f
  472.         movsx   ebx,DstY
  473.         add     ebx,es:[edi].biHeight
  474.         not     ebx
  475.         mov     DstY,bx
  476.         neg     DstWidth
  477.         neg     DstInc
  478. @@:
  479.         les     di,lpDst
  480.  
  481.         movsx   edx,DstY
  482.         mul     edx
  483.     add    edi,eax
  484.  
  485.         movsx   eax,DstX
  486.         mul     ecx
  487.         shr     eax,3
  488.         add     edi,eax
  489.  
  490.         mov     eax,lDstXE
  491.         mul     ecx
  492.         shr     eax,3
  493.         mov     DstBytes,eax
  494.         sub     DstInc,eax
  495.  
  496. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  497. ;
  498. ;  conver the bit depth (in cx) to a table index
  499. ;
  500. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  501.         sub     ecx,8                   ; cx = 0,8,16,24
  502.         shl     ecx,2                   ; cx = (0,1,2,3) * 32
  503.  
  504.         errnz   <stretch_16_functions - stretch_8_functions - 32>
  505.         errnz   <stretch_24_functions - stretch_16_functions - 32>
  506.         errnz   <stretch_32_functions - stretch_24_functions - 32>
  507.  
  508.         errnz   <x_stretch_16_functions - x_stretch_8_functions - 32>
  509.         errnz   <x_stretch_24_functions - x_stretch_16_functions - 32>
  510.         errnz   <x_stretch_32_functions - x_stretch_24_functions - 32>
  511.  
  512.         errnz   <STRETCH_1to2 - STRETCH_1to1 - 4>
  513.  
  514. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  515. ;
  516. ;  Setup y_stretch function pointer
  517. ;
  518. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  519.         mov     eax,lSrcYE
  520.         mov     edx,lDstYE
  521.         call    stretch_init_dda
  522.         mov     y_stretch_dda,edx
  523.         mov     y_stretch_dda_fract,ebx
  524.  
  525.         mov     ebx,eax
  526.         mov     edx,y_stretch_functions[ebx]
  527.         mov     y_stretch,edx
  528.  
  529. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  530. ;
  531. ;  Setup x_stretch function pointer
  532. ;
  533. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  534.         push    eax                     ; Save Y stretch type
  535.         mov     eax,lSrcXE
  536.         mov     edx,lDstXE
  537.  
  538.         call    stretch_init_dda
  539.         mov     x_stretch_dda,edx
  540.         mov     x_stretch_dda_fract,ebx
  541.  
  542.         mov     ebx,eax                 ; get x stretch
  543.         or      ebx,ecx                 ; or in bit depth
  544.         mov     edx,x_stretch_functions[ebx]
  545.         mov     x_stretch,edx
  546.  
  547. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  548. ;
  549. ;  check for a special case stretch routine
  550. ;
  551. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  552.         pop     edx                     ; get y stretch back
  553.         cmp     eax,edx                 ; is x stretch == to y stretch?
  554.         jne     short stretch_init_exit
  555.  
  556.         or      ebx,ecx
  557.         mov     edx,stretch_functions[ebx]
  558.         or      edx,edx
  559.         jz      short stretch_init_exit
  560.  
  561.         mov     y_stretch,edx           ; we have special case routine.
  562.         errn$   stretch_init_exit
  563.  
  564. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  565. ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  566.  
  567. stretch_init_exit:
  568.         clc
  569.         ret
  570.  
  571. stretch_init endp
  572.  
  573. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  574. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  575. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  576.  
  577. ;--------------------------------------------------------------------------;
  578. ;
  579. ;   y_stretch_1toN
  580. ;
  581. ;   do the entire stretch, y stretching  (DstYE > SrcYE)
  582. ;
  583. ;   Entry:
  584. ;       ds:esi  --> (SrcX, SrcY) in source
  585. ;       es:edi  --> (DstX, DstY) in destination
  586. ;       ss:bp   --> stack frame of StretchDIB
  587. ;   Returns:
  588. ;       none. (stretch is done.)
  589. ;--------------------------------------------------------------------------;
  590. y_stretch_1toN proc near
  591.         mov     ecx,lDstYE
  592.         mov     ScanCount,ecx
  593.  
  594.         mov     edx,lDstYE          ; dda error
  595.         dec     edx
  596.         mov     Yerr,edx
  597.  
  598. y_stretch_1toN_loop:
  599.         push    esi
  600.         push    edi
  601.         call    x_stretch
  602.         pop     edi
  603.         pop     esi
  604.  
  605.         add     edi, DstWidth       ; next dest scan.
  606.  
  607.         mov     eax,lSrcYE
  608.         sub     Yerr,eax
  609.         jnc     short y_stretch_1toN_next
  610.  
  611.         mov     eax,lDstYE
  612.         add     Yerr,eax
  613.  
  614.         add     esi, SrcWidth       ; next source scan.
  615.  
  616. y_stretch_1toN_next:
  617.         dec     ScanCount
  618.         jnz     short y_stretch_1toN_loop
  619.  
  620.         ret
  621.  
  622. y_stretch_1toN endp
  623.  
  624. ;--------------------------------------------------------------------------;
  625. ;
  626. ;   y_stretch_Nto1
  627. ;
  628. ;   do the entire stretch, y shrinking   (DstYE < SrcYE)
  629. ;
  630. ;   Entry:
  631. ;       ds:esi  --> (SrcX, SrcY) in source
  632. ;       es:edi  --> (DstX, DstY) in destination
  633. ;       ss:bp   --> stack frame of StretchDIB
  634. ;   Returns:
  635. ;       none. (stretch is done.)
  636. ;--------------------------------------------------------------------------;
  637. y_stretch_Nto1 proc near
  638.         mov     ecx,lDstYE
  639.         mov     ScanCount,ecx
  640.  
  641.         mov     edx,lSrcYE          ; dda error
  642.         dec     edx
  643.         mov     Yerr,edx
  644.  
  645. y_stretch_Nto1_loop:
  646.         push    esi
  647.         push    edi
  648.         call    x_stretch
  649.         pop     edi
  650.         pop     esi
  651.  
  652.         add     edi, DstWidth       ; next dest scan.
  653.  
  654.         mov     eax, lDstYE
  655. @@:     add     esi, SrcWidth       ; next source scan.
  656.         sub     Yerr, eax
  657.         jnc     short @b
  658.  
  659.         mov     eax,lSrcYE
  660.         add     Yerr,eax
  661.  
  662. y_stretch_Nto1_next:
  663.         dec     ScanCount
  664.         jnz     short y_stretch_Nto1_loop
  665.  
  666.         ret
  667.  
  668. y_stretch_Nto1 endp
  669.  
  670. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  671. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  672. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  673.  
  674. ;--------------------------------------------------------------------------;
  675. ;
  676. ;   x_stretch_1to1
  677. ;
  678. ;   handle a stretch of a scanline  (DstXE == SrcXE)
  679. ;
  680. ;   Entry:
  681. ;       ds:esi  --> begining of scan
  682. ;       es:edi  --> destination scan
  683. ;       ss:bp   --> stack frame of StretchDIB
  684. ;   Returns:
  685. ;       ds:esi  --> at end of scan
  686. ;       es:edi  --> at end of scan
  687. ;   
  688. ;--------------------------------------------------------------------------;
  689. align 4
  690. x_stretch_1to1 proc near
  691.  
  692.         mov     ecx,DstBytes        ; number of bytes to copy
  693.         mov     ebx,ecx
  694.  
  695.         shr     ecx,2               ; get count in DWORDs
  696.         rep     movs dword ptr es:[edi], dword ptr ds:[esi]
  697.         mov     ecx,ebx
  698.         and     ecx,3
  699.     rep    movs byte ptr es:[edi], byte ptr ds:[esi]
  700.         ret
  701.  
  702. x_stretch_1to1 endp
  703.  
  704. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  705. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  706. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  707.  
  708. ;--------------------------------------------------------------------------;
  709. ;
  710. ;   x_stretch_8_1toN
  711. ;
  712. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  713. ;
  714. ;   Entry:
  715. ;       ds:esi  --> begining of scan
  716. ;       es:edi  --> destination scan
  717. ;       ss:bp   --> stack frame of StretchDIB
  718. ;   Returns:
  719. ;       ds:esi  --> at end of scan
  720. ;       es:edi  --> at end of scan
  721. ;   
  722. ;--------------------------------------------------------------------------;
  723. align 4
  724. x_stretch_8_1toN proc near
  725.  
  726.         mov     ebx,x_stretch_dda_fract
  727.         xor     edx,edx
  728.         mov     ecx,lDstXE          ; # bytes to store
  729.         shr     ecx,2               ; unroll by 4
  730.         jz      short x_stretch_8_1toN_next
  731. align 4
  732. x_stretch_8_1toN_loop:
  733. rept 2
  734.         mov     al,byte ptr ds:[esi]
  735.         add     edx,ebx
  736.         adc     esi,0
  737.         mov     ah,byte ptr ds:[esi]
  738.         add     edx,ebx
  739.         adc     esi,0
  740.         ror     eax,16
  741. endm
  742.         mov     dword ptr es:[edi],eax
  743.         add     edi,4
  744.         dec     ecx
  745.         jnz     short x_stretch_8_1toN_loop
  746.  
  747. x_stretch_8_1toN_next:
  748.         mov     ecx,lDstXE
  749.         and     ecx,3
  750.         jnz     short x_stretch_8_1toN_odd
  751.         ret
  752.  
  753. x_stretch_8_1toN_odd:
  754.         mov     al,byte ptr ds:[esi]
  755.         mov     byte ptr es:[edi],al
  756.         add     edx,ebx
  757.         adc     esi,0
  758.         inc     edi
  759.         dec     ecx
  760.         jnz     short x_stretch_8_1toN_odd
  761.         ret
  762.  
  763. x_stretch_8_1toN endp
  764.  
  765. ;--------------------------------------------------------------------------;
  766. ;
  767. ;   x_stretch_8_1to2
  768. ;
  769. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  770. ;
  771. ;   Entry:
  772. ;       ds:esi  --> begining of scan
  773. ;       es:edi  --> destination scan
  774. ;       ss:bp   --> stack frame of StretchDIB
  775. ;   Returns:
  776. ;       ds:esi  --> at end of scan
  777. ;       es:edi  --> at end of scan
  778. ;   
  779. ;--------------------------------------------------------------------------;
  780. align 4
  781. x_stretch_8_1to2 proc near
  782.         mov     ecx,lSrcXE          ; loop cout
  783.         mov     ebx,ecx
  784.         shr     ecx,1
  785.         jz      short x_stretch_8_1to2_next
  786. align 4
  787. x_stretch_8_1to2_loop:
  788.         mov     ax, word ptr ds:[esi]   ; get 2 pixels
  789.         add     esi,2
  790.  
  791.         mov     edx,eax
  792.         mov     al,ah
  793.         shl     eax,16
  794.         mov     al,dl
  795.         mov     ah,dl
  796.         mov     dword ptr es:[edi], eax ; store 4
  797.         add     edi,4
  798.         dec     ecx
  799.         jnz     short x_stretch_8_1to2_loop
  800.  
  801. x_stretch_8_1to2_next:
  802.         test    ebx,1
  803.         jnz     short x_stretch_8_1to2_done
  804.         ret
  805.  
  806. x_stretch_8_1to2_done:
  807.         mov     al,byte ptr ds:[esi]
  808.         mov     ah,al
  809.         mov     word ptr es:[edi],ax
  810.         inc     esi
  811.         add     edi,2
  812.         ret
  813.  
  814. x_stretch_8_1to2 endp
  815.  
  816. ;--------------------------------------------------------------------------;
  817. ;
  818. ;   x_stretch_8_1to4
  819. ;
  820. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  821. ;
  822. ;   Entry:
  823. ;       ds:esi  --> begining of scan
  824. ;       es:edi  --> destination scan
  825. ;       ss:bp   --> stack frame of StretchDIB
  826. ;   Returns:
  827. ;       ds:esi  --> at end of scan
  828. ;       es:edi  --> at end of scan
  829. ;
  830. ;--------------------------------------------------------------------------;
  831. align 4
  832. x_stretch_8_1to4 proc near
  833.         mov     ecx,lSrcXE           ; loop cout
  834.         mov     ebx,ecx
  835.         shr     ecx,1
  836.         jz      short x_stretch_8_1to4_next
  837. align 4
  838. x_stretch_8_1to4_loop:
  839. ;       lods    word ptr ds:[esi]   ; get 2 pixels
  840.         mov     ax,word ptr ds:[esi]   ; get 2 pixels
  841.         add     esi,2
  842.  
  843.         mov     edx,eax
  844.         mov     ah,al
  845.         shl     eax,16
  846.         mov     al,dl
  847.         mov     ah,dl
  848. ;       stos    dword ptr es:[edi]  ; store 4
  849.         mov     dword ptr es:[edi],eax
  850.         add     edi,4
  851.  
  852.         mov     ax,dx
  853.         mov     al,ah
  854.         shl     eax,16
  855.         mov     ax,dx
  856.         mov     al,ah
  857. ;       stos    dword ptr es:[edi]  ; store 4
  858.         mov     dword ptr es:[edi],eax  ; store 4
  859.         add     edi,4
  860.  
  861.         dec     ecx
  862.         jnz     short x_stretch_8_1to4_loop
  863.  
  864. x_stretch_8_1to4_next:
  865.         test    ebx,1
  866.         jnz     short x_stretch_8_1to4_done
  867.         ret
  868.  
  869. x_stretch_8_1to4_done:
  870.         mov     al,byte ptr ds:[esi]
  871.         mov     ah,al
  872.         mov     dx,ax
  873.         shl     eax,16
  874.         mov     ax,dx
  875.         mov     dword ptr es:[edi],eax
  876.         inc     esi
  877.         add     edi,4
  878.         ret
  879.  
  880. x_stretch_8_1to4 endp
  881.  
  882. ;--------------------------------------------------------------------------;
  883. ;
  884. ;   x_stretch_8_Nto1
  885. ;
  886. ;   handle a shrink of a scanline  (DstXE < SrcXE)
  887. ;
  888. ;   Entry:
  889. ;       ds:esi  --> begining of scan
  890. ;       es:edi  --> destination scan
  891. ;       ecx     -   destination pixels to write
  892. ;       edx     -   source pixels to copy
  893. ;       ss:bp   --> stack frame of StretchDIB
  894. ;   Returns:
  895. ;       ds:esi  --> at end of scan
  896. ;       es:edi  --> at end of scan
  897. ;   
  898. ;--------------------------------------------------------------------------;
  899. align 4
  900. x_stretch_8_Nto1 proc near
  901.         mov     ebx,x_stretch_dda_fract
  902.         xor     edx,edx
  903.  
  904.         mov     ecx,lDstXE                      ; # bytes to store
  905.         shr     ecx,2
  906.         jz      short x_stretch_8_Nto1_cleanup
  907.  
  908.         push    ebp
  909.         mov     ebp,x_stretch_dda
  910. align 4
  911. x_stretch_8_Nto1_loop:
  912. rept    4
  913.         mov     al,byte ptr ds:[esi]
  914.         ror     eax,8
  915.         add     edx,ebx
  916.         adc     esi,ebp
  917. endm
  918.         mov     dword ptr es:[edi],eax
  919.         add     edi,4
  920.         dec     ecx
  921.         jnz     short x_stretch_8_Nto1_loop
  922.         pop     ebp
  923.  
  924. x_stretch_8_Nto1_cleanup:
  925.         mov     ecx,lDstXE
  926.         and     ecx,011b
  927.         jnz     short x_stretch_8_Nto1_loop2
  928.         ret
  929.  
  930. x_stretch_8_Nto1_loop2:
  931.         mov     al,byte ptr ds:[esi]
  932.         mov     byte ptr es:[edi],al
  933.         inc     edi
  934.         add     edx,ebx
  935.         adc     esi,x_stretch_dda
  936.         dec     ecx
  937.         jnz     short x_stretch_8_Nto1_loop2
  938.         ret
  939.  
  940. x_stretch_8_Nto1 endp
  941.  
  942. ;--------------------------------------------------------------------------;
  943. ;
  944. ;   stretch_8_1to2
  945. ;
  946. ;   handle a x2 stretch of a entire image
  947. ;
  948. ;   Entry:
  949. ;       ds:esi  --> begining of scan
  950. ;       es:edi  --> destination scan
  951. ;       ss:bp   --> stack frame of StretchDIB
  952. ;   Returns:
  953. ;       ds:esi  --> at end of scan
  954. ;       es:edi  --> at end of scan
  955. ;   
  956. ;--------------------------------------------------------------------------;
  957. align 4
  958. stretch_8_1to2 proc near
  959.         mov     eax, DstWidth
  960.         add     DstInc, eax
  961.  
  962.         mov     ecx, lSrcXE
  963.         mov     ebx, DstWidth
  964. align 4
  965. stretch_8_1to2_outer_loop:
  966.         mov     ecx,lSrcXE          ; loop cout (/4)
  967.         shr     ecx,2
  968.         jz      short stretch_8_1to2_next
  969. align 4
  970. stretch_8_1to2_loop:
  971.         mov     edx, dword ptr ds:[esi]   ; get 4 pixels
  972.         mov     al,dh
  973.         mov     ah,dh
  974.         shl     eax,16
  975.         mov     al,dl
  976.         mov     ah,dl
  977.         mov     dword ptr es:[edi], eax     ; store 4
  978.         mov     dword ptr es:[edi+ebx], eax ; store 4
  979.  
  980.         shr     edx,16
  981.  
  982.         mov     al,dh
  983.         mov     ah,dh
  984.         shl     eax,16
  985.         mov     al,dl
  986.         mov     ah,dl
  987.         mov     dword ptr es:[edi+4], eax     ; store 4
  988.         mov     dword ptr es:[edi+4+ebx], eax ; store 4
  989.  
  990.         add     edi,8
  991.         add     esi,4
  992.  
  993.         dec     ecx
  994.         jnz     short stretch_8_1to2_loop
  995.  
  996. stretch_8_1to2_next:
  997.         mov     ecx,lSrcXE
  998.         and     ecx,3
  999.         jnz     short stretch_8_1to2_odd
  1000.  
  1001. stretch_8_1to2_even:
  1002.         add     edi, DstInc
  1003.         add     esi, SrcInc
  1004.  
  1005.         dec     lSrcYE
  1006.         jnz     short stretch_8_1to2_outer_loop
  1007.         ret
  1008.  
  1009. stretch_8_1to2_odd:
  1010.         mov     al,byte ptr ds:[esi]
  1011.         mov     ah,al
  1012.         mov     word ptr es:[edi],ax
  1013.         mov     word ptr es:[edi+ebx],ax
  1014.         inc     esi
  1015.         add     edi,2
  1016.         dec     ecx
  1017.         jnz     short stretch_8_1to2_odd
  1018.         jz      short stretch_8_1to2_even
  1019.  
  1020. stretch_8_1to2 endp
  1021.  
  1022.  
  1023. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1024. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1025. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1026.  
  1027. ;--------------------------------------------------------------------------;
  1028. ;
  1029. ;   x_stretch_16_1toN
  1030. ;
  1031. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  1032. ;
  1033. ;   Entry:
  1034. ;       ds:esi  --> begining of scan
  1035. ;       es:edi  --> destination scan
  1036. ;       ss:bp   --> stack frame of StretchDIB
  1037. ;   Returns:
  1038. ;       ds:esi  --> at end of scan
  1039. ;       es:edi  --> at end of scan
  1040. ;   
  1041. ;--------------------------------------------------------------------------;
  1042. align 4
  1043. x_stretch_16_1toN proc near
  1044.         xor     edx,edx
  1045.  
  1046.         mov     ecx,lDstXE
  1047.         shr     ecx,1
  1048.         jz      short x_stretch_16_1toN_cleanup
  1049.  
  1050. align 4
  1051. x_stretch_16_1toN_loop:
  1052. rept 2
  1053.         mov     ax,word ptr ds:[esi]
  1054.         ror     eax,16
  1055.  
  1056.         add     edx, x_stretch_dda_fract
  1057.         sbb     ebx, ebx                ; ebx = CF ? -1 : 0
  1058.         and     ebx, 2
  1059.         add     esi, ebx
  1060. endm
  1061.         mov     dword ptr es:[edi],eax
  1062.         add     edi,4
  1063.  
  1064.         dec     ecx
  1065.         jnz     short x_stretch_16_1toN_loop
  1066.  
  1067. x_stretch_16_1toN_cleanup:
  1068.         test    byte ptr DstXE, 1
  1069.         jnz     short x_stretch_16_1toN_odd
  1070.         ret
  1071.  
  1072. x_stretch_16_1toN_odd:
  1073.         mov     ax,word ptr ds:[esi]
  1074.         mov     word ptr es:[edi],ax
  1075.         add     esi,2
  1076.         add     edi,2
  1077.         ret
  1078.  
  1079. x_stretch_16_1toN endp
  1080.  
  1081. ;--------------------------------------------------------------------------;
  1082. ;
  1083. ;   x_stretch_16_1to2
  1084. ;
  1085. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  1086. ;
  1087. ;   Entry:
  1088. ;       ds:esi  --> begining of scan
  1089. ;       es:edi  --> destination scan
  1090. ;       ss:bp   --> stack frame of StretchDIB
  1091. ;   Returns:
  1092. ;       ds:esi  --> at end of scan
  1093. ;       es:edi  --> at end of scan
  1094. ;   
  1095. ;--------------------------------------------------------------------------;
  1096. align 4
  1097. x_stretch_16_1to2 proc near
  1098.         mov     ecx,lSrcXE          ; loop cout
  1099.         mov     ebx,ecx
  1100.         shr     ecx,1
  1101.         jz      short x_stretch_16_1to2_done
  1102. align 4
  1103. x_stretch_16_1to2_loop:
  1104.     mov    eax, dword ptr ds:[esi] ; get 2 pixels
  1105.     add    esi,4
  1106.  
  1107.     mov    edx,eax
  1108.         shl     eax,16
  1109.         mov     ax,dx
  1110.     mov    dword ptr es:[edi], eax ; store 2
  1111.     add    edi,4
  1112.  
  1113.     mov    eax,edx
  1114.     shr    edx,16
  1115.         mov     ax,dx
  1116.     mov    dword ptr es:[edi], eax ; store 2
  1117.     add    edi,4
  1118.  
  1119.         dec     ecx
  1120.         jnz     short x_stretch_16_1to2_loop
  1121.  
  1122. x_stretch_16_1to2_done:
  1123.         test    ebx,1
  1124.         jnz     short x_stretch_16_1to2_odd
  1125.         ret
  1126.  
  1127. x_stretch_16_1to2_odd:
  1128.         mov     bx,word ptr ds:[esi]
  1129.         mov     eax,ebx
  1130.         shl     eax,16
  1131.         mov     ax,bx
  1132.         mov     dword ptr es:[edi],eax
  1133.         add     esi,2
  1134.         add     edi,4
  1135.         ret
  1136.  
  1137. x_stretch_16_1to2 endp
  1138.  
  1139. ;--------------------------------------------------------------------------;
  1140. ;
  1141. ;   x_stretch_16_Nto1
  1142. ;
  1143. ;   handle a shrink of a scanline  (DstXE < SrcXE)
  1144. ;
  1145. ;   Entry:
  1146. ;       ds:esi  --> begining of scan
  1147. ;       es:edi  --> destination scan
  1148. ;       ecx     -   destination pixels to write
  1149. ;       edx     -   source pixels to copy
  1150. ;       ss:bp   --> stack frame of StretchDIB
  1151. ;   Returns:
  1152. ;       ds:esi  --> at end of scan
  1153. ;       es:edi  --> at end of scan
  1154. ;   
  1155. ;--------------------------------------------------------------------------;
  1156. align 4
  1157. x_stretch_16_Nto1 proc near
  1158.         mov     ecx,lDstXE            ; # loop count
  1159.         mov     ebx,x_stretch_dda_fract
  1160.         xor     edx,edx
  1161.  
  1162.         push    ebp
  1163.         mov     ebp,x_stretch_dda
  1164.         dec     ebp
  1165.         add     ebp,ebp
  1166. align 4
  1167. x_stretch_16_Nto1_loop:
  1168.         movs    word ptr es:[edi], word ptr ds:[esi]
  1169.         add     esi,ebp
  1170.         add     edx,ebx
  1171.         sbb     eax,eax
  1172.         and     eax,2
  1173.         add     esi,eax
  1174.  
  1175.         dec     ecx
  1176.         jnz     short x_stretch_16_Nto1_loop
  1177.         pop     ebp
  1178.  
  1179. x_stretch_16_Nto1_exit:
  1180.         ret
  1181.  
  1182. x_stretch_16_Nto1 endp
  1183.  
  1184. ;--------------------------------------------------------------------------;
  1185. ;
  1186. ;   stretch_16_1to2
  1187. ;
  1188. ;   handle a x2 stretch of a entire image
  1189. ;
  1190. ;   Entry:
  1191. ;       ds:esi  --> begining of scan
  1192. ;       es:edi  --> destination scan
  1193. ;       ss:bp   --> stack frame of StretchDIB
  1194. ;   Returns:
  1195. ;       ds:esi  --> at end of scan
  1196. ;       es:edi  --> at end of scan
  1197. ;   
  1198. ;--------------------------------------------------------------------------;
  1199. align 4
  1200. stretch_16_1to2 proc near
  1201.         mov     ebx, DstWidth
  1202.         add     DstInc, ebx
  1203. align 4
  1204. stretch_16_1to2_outer_loop:
  1205.         mov     ecx,lSrcXE                 ; loop cout (/2)
  1206.         shr     ecx,1
  1207.         jz      short stretch_16_1to2_next
  1208. align 4
  1209. stretch_16_1to2_loop:
  1210.         mov     edx, dword ptr ds:[esi]   ; get 2 pixels
  1211.  
  1212.         mov     ax,dx
  1213.         shl     eax,16
  1214.         mov     ax,dx
  1215.         mov     dword ptr es:[edi], eax     ; store 2
  1216.         mov     dword ptr es:[edi+ebx], eax ; store 2
  1217.  
  1218.         shr     edx,16
  1219.  
  1220.         mov     ax,dx
  1221.         shl     eax,16
  1222.         mov     ax,dx
  1223.         mov     dword ptr es:[edi+4], eax     ; store 2
  1224.         mov     dword ptr es:[edi+4+ebx], eax ; store 2
  1225.  
  1226.         add     edi,8
  1227.         add     esi,4
  1228.  
  1229.         dec     ecx
  1230.         jnz     short stretch_16_1to2_loop
  1231.  
  1232. stretch_16_1to2_next:
  1233.         test    lSrcXE,1
  1234.         jnz     short stretch_16_1to2_odd
  1235.  
  1236. stretch_16_1to2_even:
  1237.         add     edi, DstInc
  1238.         add     esi, SrcInc
  1239.  
  1240.         dec     SrcYE
  1241.         jnz     short stretch_16_1to2_outer_loop
  1242.         ret
  1243.  
  1244. stretch_16_1to2_odd:
  1245.         mov     dx,word ptr ds:[esi]
  1246.         mov     ax,dx
  1247.         shl     eax,16
  1248.         mov     ax,dx
  1249.         mov     dword ptr es:[edi],eax
  1250.         mov     dword ptr es:[edi+ebx],eax
  1251.         add     esi,2
  1252.         add     edi,4
  1253.         jmp     short stretch_16_1to2_even
  1254.  
  1255. stretch_16_1to2 endp
  1256.  
  1257. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1258. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;24 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1259. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1260.  
  1261. ;--------------------------------------------------------------------------;
  1262. ;
  1263. ;   x_stretch_24_1toN
  1264. ;
  1265. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  1266. ;
  1267. ;   Entry:
  1268. ;       ds:esi  --> begining of scan
  1269. ;       es:edi  --> destination scan
  1270. ;       ss:bp   --> stack frame of StretchDIB
  1271. ;   Returns:
  1272. ;       ds:esi  --> at end of scan
  1273. ;       es:edi  --> at end of scan
  1274. ;   
  1275. ;--------------------------------------------------------------------------;
  1276. align 4
  1277. x_stretch_24_1toN proc near
  1278.  
  1279.         mov     ecx,lDstXE            ; # loop count
  1280.         mov     ebx,x_stretch_dda_fract
  1281.         xor     edx,edx
  1282. align 4
  1283. x_stretch_24_1toN_loop:
  1284.         movs    word ptr es:[edi], word ptr ds:[esi]
  1285.         movs    byte ptr es:[edi], byte ptr ds:[esi]
  1286.         add     edx,ebx
  1287.         sbb     eax,eax
  1288.         not     eax
  1289.         and     eax,-3
  1290.         add     esi,eax
  1291.  
  1292.         dec     ecx
  1293.         jnz     short x_stretch_24_1toN_loop
  1294.  
  1295. x_stretch_24_1toN_exit:
  1296.         ret
  1297.  
  1298. x_stretch_24_1toN endp
  1299.  
  1300. ;--------------------------------------------------------------------------;
  1301. ;
  1302. ;   x_stretch_24_Nto1
  1303. ;
  1304. ;   handle a shrink of a scanline  (DstXE < SrcXE)
  1305. ;
  1306. ;   Entry:
  1307. ;       ds:esi  --> begining of scan
  1308. ;       es:edi  --> destination scan
  1309. ;       ecx     -   destination pixels to write
  1310. ;       edx     -   source pixels to copy
  1311. ;       ss:bp   --> stack frame of StretchDIB
  1312. ;   Returns:
  1313. ;       ds:esi  --> at end of scan
  1314. ;       es:edi  --> at end of scan
  1315. ;   
  1316. ;--------------------------------------------------------------------------;
  1317. align 4
  1318. x_stretch_24_Nto1 proc near
  1319.         mov     ecx,lDstXE            ; # loop count
  1320.         mov     ebx,x_stretch_dda_fract
  1321.         xor     edx,edx
  1322.  
  1323.         push    ebp
  1324.         mov     ebp,x_stretch_dda
  1325.         dec     ebp
  1326.         mov     eax,ebp
  1327.         add     ebp,ebp
  1328.         add     ebp,eax
  1329. align 4
  1330. x_stretch_24_Nto1_loop:
  1331.         movs    word ptr es:[edi], word ptr ds:[esi]
  1332.         movs    byte ptr es:[edi], byte ptr ds:[esi]
  1333.         add     esi,ebp
  1334.         add     edx,ebx
  1335.         sbb     eax,eax
  1336.         and     eax,3
  1337.         add     esi,eax
  1338.  
  1339.         dec     ecx
  1340.         jnz     short x_stretch_24_Nto1_loop
  1341.         pop     ebp
  1342.  
  1343. x_stretch_24_Nto1_exit:
  1344.         ret
  1345.  
  1346. x_stretch_24_Nto1 endp
  1347.  
  1348. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1349. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;32 BIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1350. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1351.  
  1352. ;--------------------------------------------------------------------------;
  1353. ;
  1354. ;   x_stretch_32_1toN
  1355. ;
  1356. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  1357. ;
  1358. ;   Entry:
  1359. ;       ds:esi  --> begining of scan
  1360. ;       es:edi  --> destination scan
  1361. ;       ss:bp   --> stack frame of StretchDIB
  1362. ;   Returns:
  1363. ;       ds:esi  --> at end of scan
  1364. ;       es:edi  --> at end of scan
  1365. ;   
  1366. ;--------------------------------------------------------------------------;
  1367. align 4
  1368. x_stretch_32_1toN proc near
  1369.         xor     edx,edx
  1370.  
  1371.         mov     ecx,lDstXE
  1372. align 4
  1373. x_stretch_32_1toN_loop:
  1374.         mov     eax,word ptr ds:[esi]
  1375.         add     edx, x_stretch_dda_fract
  1376.         sbb     ebx, ebx                ; ebx = CF ? -1 : 0
  1377.         and     ebx, 4
  1378.         add     esi, ebx
  1379.         mov     dword ptr es:[edi],eax
  1380.         add     edi,4
  1381.  
  1382.         dec     ecx
  1383.         jnz     short x_stretch_32_1toN_loop
  1384.  
  1385.         ret
  1386.  
  1387. x_stretch_32_1toN endp
  1388.  
  1389. ;--------------------------------------------------------------------------;
  1390. ;
  1391. ;   x_stretch_32_1to2
  1392. ;
  1393. ;   handle a stretch of a scanline  (DstXE > SrcXE)
  1394. ;
  1395. ;   Entry:
  1396. ;       ds:esi  --> begining of scan
  1397. ;       es:edi  --> destination scan
  1398. ;       ss:bp   --> stack frame of StretchDIB
  1399. ;   Returns:
  1400. ;       ds:esi  --> at end of scan
  1401. ;       es:edi  --> at end of scan
  1402. ;   
  1403. ;--------------------------------------------------------------------------;
  1404. align 4
  1405. x_stretch_32_1to2 proc near
  1406.         mov     ecx,lSrcXE          ; loop cout
  1407. align 4
  1408. x_stretch_32_1to2_loop:
  1409.         mov     eax, dword ptr ds:[esi]     ; get a pel
  1410.         mov     dword ptr es:[edi], eax     ; store it
  1411.         add     esi,4
  1412.         mov     dword ptr es:[edi+4], eax   ; store it again
  1413.         add     edi,8
  1414.  
  1415.         dec     ecx
  1416.         jnz     short x_stretch_32_1to2_loop
  1417.  
  1418. x_stretch_32_1to2_done:
  1419.         ret
  1420.  
  1421. x_stretch_32_1to2 endp
  1422.  
  1423. ;--------------------------------------------------------------------------;
  1424. ;
  1425. ;   x_stretch_32_Nto1
  1426. ;
  1427. ;   handle a shrink of a scanline  (DstXE < SrcXE)
  1428. ;
  1429. ;   Entry:
  1430. ;       ds:esi  --> begining of scan
  1431. ;       es:edi  --> destination scan
  1432. ;       ecx     -   destination pixels to write
  1433. ;       edx     -   source pixels to copy
  1434. ;       ss:bp   --> stack frame of StretchDIB
  1435. ;   Returns:
  1436. ;       ds:esi  --> at end of scan
  1437. ;       es:edi  --> at end of scan
  1438. ;   
  1439. ;--------------------------------------------------------------------------;
  1440. align 4
  1441. x_stretch_32_Nto1 proc near
  1442.         mov     ecx,lDstXE            ; # loop count
  1443.         mov     ebx,x_stretch_dda_fract
  1444.         xor     edx,edx
  1445.  
  1446.         push    ebp
  1447.         mov     ebp,x_stretch_dda
  1448.         dec     ebp
  1449.         add     ebp,ebp
  1450.         add     ebp,ebp
  1451. align 4
  1452. x_stretch_32_Nto1_loop:
  1453.         movs    dword ptr es:[edi], dword ptr ds:[esi]
  1454.         add     esi,ebp
  1455.         add     edx,ebx
  1456.         sbb     eax,eax
  1457.         and     eax,4
  1458.         add     esi,eax
  1459.  
  1460.         dec     ecx
  1461.         jnz     short x_stretch_32_Nto1_loop
  1462.         pop     ebp
  1463.  
  1464. x_stretch_32_Nto1_exit:
  1465.         ret
  1466.  
  1467. x_stretch_32_Nto1 endp
  1468.  
  1469. sEnd    CodeSeg
  1470.  
  1471. end
  1472.